//
//  FirstTwoTableCell.m
//  轮胎商城
//
//  Created by 张晋磊 on 2017/3/23.
//  Copyright © 2017年 张晋磊. All rights reserved.
//

#import "FirstTwoTableCell.h"

@interface FirstTwoTableCell ()

@property (nonatomic,copy) MyBlock block;

@end

@implementation FirstTwoTableCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
    
        CGSize size = [UIScreen mainScreen].bounds.size;
        
        UIButton *bt1 = [UIButton buttonWithType:UIButtonTypeCustom];
        bt1.frame = CGRectMake(0, 0, size.width/2-2, 90);
        [bt1 setTitle:@"矿山车胎" forState:UIControlStateNormal];
        [bt1 setBackgroundColor:[UIColor greenColor]];
        [bt1 addTarget:self action:@selector(clickBt:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:bt1];
        
        UIButton *bt2 = [UIButton buttonWithType:UIButtonTypeCustom];
        bt2.frame = CGRectMake(size.width/2, 0, size.width/2-2, 90);
        [bt2 setTitle:@"自行车胎" forState:UIControlStateNormal];
        [bt2 setBackgroundColor:[UIColor greenColor]];
        [bt2 addTarget:self action:@selector(clickBt:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:bt2];
        
        UIButton *bt3 = [UIButton buttonWithType:UIButtonTypeCustom];
        bt3.frame = CGRectMake(0, 92, size.width/2-2, 90);
        [bt3 setTitle:@"摩托车胎" forState:UIControlStateNormal];
        [bt3 setBackgroundColor:[UIColor greenColor]];
        [bt3 addTarget:self action:@selector(clickBt:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:bt3];
        
        UIButton *bt4 = [UIButton buttonWithType:UIButtonTypeCustom];
        bt4.frame = CGRectMake(size.width/2, 92, size.width/2-2, 90);
        [bt4 setTitle:@"工业车胎" forState:UIControlStateNormal];
        [bt4 setBackgroundColor:[UIColor greenColor]];
        [bt4 addTarget:self action:@selector(clickBt:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:bt4];
        
        
    }
    return self;
}

-(void)clickBt:(UIButton *)bt{

    if(_block){
    
        _block(bt.titleLabel.text);
        NSLog(@"%@",_block(bt.titleLabel.text));
    }
}

-(void)computeBlockGetUrl:(NSString *(^)(NSString *))block{

    if(_block != block){
    
        _block = block;
    }
}


@end
